<!DOCTYPE HTML>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns="http://www.w3.org/1999/html">
<meta charset="utf-8">
<head th:include="include :: header"></head>
<link th:href="@{/ajax/libs/summernote/summernote.css}" rel="stylesheet"/>
<link th:href="@{/ajax/libs/summernote/summernote-bs3.css}" rel="stylesheet"/>

<body class="white-bg">
    <div class="wrapper wrapper-content animated fadeInRight ibox-content">
        <form class="form-horizontal m" id="form-goodsinfo-add">
			<div class="form-group">	
				<label class="col-sm-3 control-label">所属分类：</label>
				<div class="col-sm-8">
					<select id="businesstypeId" name="businesstypeId" class="form-control">
						<option th:each="goodInfo:${goodTypes}" th:value="${goodInfo.mallcategoryId}" th:text="${goodInfo.name}"></option>
					</select>

				</div>
			</div>
			<div class="form-group">	
				<label class="col-sm-3 control-label">商品价格：</label>
				<div class="col-sm-8">
					<input id="goodsPrice" name="goodsPrice" class="form-control" type="text">
				</div>
			</div>
			<div class="form-group">	
				<label class="col-sm-3 control-label">会员价格：</label>
				<div class="col-sm-8">
					<input id="memberPrice" name="memberPrice" class="form-control" type="text">
				</div>
			</div>
			<div class="form-group">	
				<label class="col-sm-3 control-label">积分价格：</label>
				<div class="col-sm-8">
					<input id="integralPrice" name="integralPrice" class="form-control" type="text">
				</div>
			</div>

			<div class="form-group">	
				<label class="col-sm-3 control-label">展示优先级：</label>
				<div class="col-sm-8">
					<input id="sortPriority" name="sortPriority" class="form-control" type="text">
				</div>
			</div>
			<div class="form-group">	
				<label class="col-sm-3 control-label">库存数量：</label>
				<div class="col-sm-8">
					<input id="kuCun" name="kuCun" class="form-control" type="text">
				</div>
			</div>

			<div class="form-group">
				<label class="col-sm-3 control-label">开启拼单：</label>
				<div class="col-sm-8">
					<div class="onoffswitch">
						<input type="checkbox" th:checked="true" class="onoffswitch-checkbox" id="pindan" name="pindan">
						<label class="onoffswitch-label" for="pindan">
							<span class="onoffswitch-inner"></span>
							<span class="onoffswitch-switch"></span>
						</label>
					</div>

				</div>
			</div>
			<div class="form-group">
				<label class="col-sm-3 control-label">商品描述：</label>
				<div class="col-sm-8">
					<input id="goodsDescribe" name="goodsDescribe" type="hidden">
					<div class="shangpinmiaoshu"></div>

				</div>
			</div>

			<div class="form-group">
				<label class="font-noraml">多文件上传</label>
				<div class="file-loading">
					<input id="fileinput-demo-1" type="file" multiple>
				</div>
			</div>

		</form>
	</div>
    <div th:include="include::footer"></div>
	<script th:src="@{/ajax/libs/summernote/summernote.min.js}"></script>
	<script th:src="@{/ajax/libs/summernote/summernote-zh-CN.js}"></script>

    <script type="text/javascript">
		var prefix = ctx + "system/goodsinfo"

		$("#form-goodsinfo-add").validate({
			rules:{
				xxxx:{
					required:true,
				},
			}
		});
		
		function submitHandler() {
	        if ($.validate.form()) {
				var sHTML = $('.shangpinmiaoshu').summernote('code');
				$("#goodsDescribe").val(sHTML);
	            $.operate.save(prefix + "/add", $('#form-goodsinfo-add').serialize());
	        }
	    }
		$('.shangpinmiaoshu').summernote({
			height: '220px',
			lang: 'zh-CN',
			onImageUpload:function (files,editor,$editable) {
				var $files = $(files);
				$files.each(function () {
					var file = this;
					var data = new FormData();
					data.append("file",file);
					$.ajax({
						data:data,
						url:ctx + "common/upload",
						cacne:false,
						contentType:false,
						processData:false,
						success:function (response) {
							var imageUrl = response.msg;
							editor.insertImage($editable,ctx+"profile/"+imageUrl,response.fileName);
						}
					})
				})
			}

		});
		/*$('.shangpinmiaoshu').summernote({
			height : '220px',
			lang : 'zh-CN',
			callbacks: {
				onImageUpload: function (files) {
					sendFile(files[0], this);
				}
			}
		});
		// 上传文件
		function sendFile(file, obj) {
			var data = new FormData();
			data.append("file", file);
			$.ajax({
				type: "POST",
				url: ctx + "common/upload",
				data: data,
				cache: false,
				contentType: false,
				processData: false,
				dataType: 'json',
				success: function(result) {
					if (result.code == web_status.SUCCESS) {
						$(obj).summernote('editor.insertImage', result.url, result.fileName);
					} else {
						$.modal.alertError(result.msg);
					}
				},
				error: function(error) {
					$.modal.alertWarning("图片上传失败。");
				}
			});
		}*/
	</script>
</body>
</html>
